﻿package mortal.game.view.guide
{
    import baseEngine.modifiers.*;
    import com.gengine.global.*;
    import flash.geom.*;
    import frEngine.pools.*;
    import frEngine.render.layer.uiEffectLayer.*;
    import mortal.component.gconst.*;
    import mortal.game.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.ai.singleAIs.autofight.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.view.task.data.*;
    import mortal.game.view.task.drama.*;

    public class GuideEffect extends Object
    {
        public static var isShowPath:Boolean = true;
        private static var _pathEffect:GroupEffectPlayer;
        private static var _isFighting:Boolean = false;
        private static var _fightEffect:EffectPlayer;

        public function GuideEffect()
        {
            return;
        }// end function

        public static function showAutoPathStatus(param1:Boolean = true) : void
        {
            if (param1 && !_isFighting && isShowPath && !TaskDramaOperator.isInFlyDrama)
            {
                if (_pathEffect == null || _pathEffect.isDisposed)
                {
                    _pathEffect = FrObjectPool.getObject(GroupEffectPlayer, "GuideEffect");
                }
                _pathEffect.load(GlobalStaticResUrl.AutoPath, false, UIEffectList.instance.getRenderListByUILayerID(UILayerIDs.TextID));
                _pathEffect.y = -155;
                Game.scene.addChild(_pathEffect);
                _pathEffect.play(PlayMode.ANIMATION_STOP_MODE);
            }
            else if (_pathEffect != null)
            {
                _pathEffect.dispose(true);
                _pathEffect.parent = null;
                _pathEffect = null;
            }
            return;
        }// end function

        public static function showAutoFightStatus(param1:Boolean = true) : void
        {
            var _loc_2:String = null;
            if (param1)
            {
                showAutoPathStatus(false);
                _isFighting = true;
                _loc_2 = GlobalStaticResUrl.AutoFight;
                if (AutoFightBossSelectAI.instance.range == GameConst.RoundFightDistance)
                {
                    _loc_2 = GlobalStaticResUrl.RoundFight;
                }
                if (_fightEffect == null)
                {
                    _fightEffect = EffectPlayerPool.instance.getEffectPlayer(_loc_2, Game.scene, UIEffectList.instance.getRenderListByUILayerID(UILayerIDs.TextID), false);
                }
                _fightEffect.y = -155;
                _fightEffect.play(PlayMode.ANIMATION_LOOP_MODE);
            }
            else if (_fightEffect != null)
            {
                _isFighting = false;
                _fightEffect.dispose(true);
                _fightEffect.parent = null;
                _fightEffect = null;
            }
            return;
        }// end function

        public static function getGuideEffectY() : int
        {
            if (GameController.npc.isTaskDialogHide())
            {
                return 200;
            }
            var _loc_1:* = (Global.stage.stageHeight - 382) / 2 - 60;
            var _loc_2:* = LayerManager.actionIconLayer.myHeight + LayerManager.actionIconLayer.y;
            if (_loc_2 > _loc_1)
            {
                return Global.stage.stageHeight / 2 - 25 - _loc_2 - 5;
            }
            return 236;
        }// end function

        public static function playAddExpEffect(param1:int, param2:int, param3:int, param4:Function = null, param5:int = -1, param6:int = -1, param7:int = 5, param8:Boolean = false) : void
        {
            if (param1 < 5000)
            {
                if (param4 != null)
                {
                    param4.apply();
                }
                return;
            }
            if (param5 == -1 && param6 == -1)
            {
                param5 = Global.stage.stageWidth / 2;
                param6 = Global.stage.stageHeight / 2;
            }
            GuideFlyEffect.instance.work(new Point(param5, param6), new Point(param2, param3), 16, 80, param4, param7, param8);
            return;
        }// end function

    }
}
